import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class LevelWidget extends StatelessWidget {
  final int memberLevel;
  final Function() onTap;

  const LevelWidget({Key? key, required this.memberLevel, required this.onTap})
    : super(key: key);

  // 根据会员等级获取钻石颜色
  Color getDiamondColor(int level) {
    switch (level) {
      case 1:
        return Colors.grey;
      case 2:
        return Colors.blueGrey;
      case 3:
        return Colors.lightBlue;
      case 4:
        return Colors.blue;
      case 5:
        return Colors.deepPurpleAccent;
      case 6:
        return Colors.purple;
      case 7:
        return Colors.deepPurple;
      default:
        return Colors.grey;
    }
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.end,
        children: [
          Icon(Icons.diamond, color: getDiamondColor(memberLevel), size: 20),
          const SizedBox(width: 3),
          Text(
            '${memberLevel}级',
            style: TextStyle(
              fontSize: 14,
              color: getDiamondColor(memberLevel),
              fontWeight: FontWeight.bold,
            ),
          ),
        ],
      ),
    );
  }
}
